<?php 
class Front_PrintPayment_Generic extends System_Db_Generic  {
	public function getPaymentDetail($paymentId){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Payment_Get_translist '".$paymentId."', NULL, NULL, NULL, NULL";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['payment_datetime'] = getDateFormat2($results[$key]['payment_datetime']);
		}
		return $results['0'];
	}
	
	public function getPreAuthById($preauth_id,$user_id){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Preauth_Get_translist '".$preauth_id."',NULL,NULL,'".$user_id."',NULL";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['preauth_datetime'] = getDateFormat2($results[$key]['preauth_datetime']);
		}
	}
	public function getPolicyById($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_member_queryByPolicyID '$policy_id'";
		//echo $cmd_exec; exit();
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['effective'] = getDateFormat2($results[$key]['effective']);
			$results[$key]['expiry'] = getDateFormat2($results[$key]['expiry']);
			$results[$key]['me_cover'] = number_format($results[$key]['me_cover'],2,'.',',');
			$results[$key]['mc_cover'] = number_format($results[$key]['mc_cover'],2,'.',',');
		}
		return $results['0'];
	}
	
	public function getClaimCover(){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Claim_Get_Cover_Type NULL";
		//echo $cmd_exec; exit();
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results;
	}
	//--beerz
	public function updatePaymentImage($paymentId,$img_data){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.SP_elink_Common_SaveFile 'elink_Payment_Trans','payment_img','AND(#)Payment_ID=''$paymentId''','''$img_data'''";
		$statement = $db->prepare($cmd_exec);
		$results = $statement->execute();
		return $results;
	}
	public function updateCancelImage($cancelId,$img_data){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.SP_elink_Common_SaveFile 'elink_Cancel_Trans','cancel_img','AND(#)cancel_ID=''$cancelId''','''$img_data'''";
		$statement = $db->prepare($cmd_exec);
		$results = $statement->execute();
		return $results;
	}
	public function getPaymentImage($paymentId){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "select payment_img from elink_Payment_Trans where Payment_ID = '$paymentId'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
	public function getCancelImage($paymentId){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "select cancel_img from elink_cancel_Trans where Payment_ID = '$paymentId'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
	public function getPaymentIDbyPreautID($preauth_id){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "SELECT isnull(max(Payment_ID),0) as payment_id FROM elink_Payment_Trans where PreAuth_ID = '$preauth_id' ";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0']['payment_id'];
	}
	public function getCancelId(){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_common_GenID 'cancel'";
		$statement = $db->prepare($cmd_exec);
	
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0']['new_id'];
	}
	public function insertCancel($cancel_id,$payment_id,$userid){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Cancel_Trans_Save '".$cancel_id."','".$payment_id."','".$userid."'";
		$statement = $db->prepare($cmd_exec);
		$results = $statement->execute();
		return $results;
	}
	
	//--beerz
}
?>